<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="target-densitydpi=640,width=1280,user-scalable=yes">
    <base href="<?php echo $system['siteRoot'];?>" />
    <title>订单详情</title>
    <?php import_tpl("fragment/icon.php"); ?>
    <link rel="stylesheet" href="plugin/reset.css"/>
    <link rel="stylesheet" href="plugin/awesome4/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="style/common.css"/>
    <link rel="stylesheet" href="style/my-order.css"/>
    <link rel="stylesheet" href="style/putuan-order.css"/>
    <link rel="stylesheet" href="style/order-details.css"/>
    <script src="plugin/jquery-1.11.2.min.js"></script>
    <script type="text/javascript">
    (function(){
        $(function(){
            //console.log( $('.slide .commodity'))
            $('.slide .order').addClass('menu-normal').removeClass('menu-label')    
        })
    })()
    </script>
    <script type="text/javascript">_root='<?php echo $system['siteRoot'];?>'</script>
    <script type="text/javascript"> IS_IE9 = false; </script>
    
    <!-- 照顾低能浏览器 -->
    <!--[if lt IE 9]>
    <script type="text/javascript"> IS_IE9 = true; </script>
    <![endif]-->
    <script src="script/api.js"></script>
    <script>
        function refund() {
            return !!confirm("确定要退货/退款吗？");
        }
        function cancel(){
            return !!confirm("确定要取消订单吗？取消后将消失在列表中");
        }
    </script>
    <script src="script/order-list.js"></script>
</head>
<body>
<div id="container" class="index">
    <?php import_part("custom.home","userBar"); ?>
    <?php import_part("custom.home","header"); ?>
    <?php import_tpl("fragment/nav.php"); ?>
    <div class="main-container">
        <div class="left">
            <?php import_tpl("fragment/mySlide.php"); ?>
            <div class="qr-code-box">
                <img src="images/weixin.png" alt="扫描二维码关注" title="关注我们的微信"/>
                <div>
                    <p class="weixin">扫描二维码</p>
                    <p class="concern">关注我们的微信</p>
                </div>
            </div>
        </div>
        <div class="right">
            <div class="my-order">
                <div class="myorder-bg">
                    <div class="myorder-title">
                        <p>订单详情</p>
                    </div>
                    <div class="order">
                        <table>
                            <tr>
                            <td class="cargo-img"></td>
                            <td class="cargo-name">商品名称</td>
                            <td class="cargo-price">单价</td>
                            <td class="cargo-amount">数量</td>
                            <td class="total-fee">实付款</td>
                            <td class="order-evaluation">操作</td>
                            </tr>
                        </table>
                    </div>
                    <table class="order-detail">
                        <tr class="order-brief">
                            <td class="order-time" colspan="6"><?=$r['order']['create_time']?>  |  订单号：<?=$r['order']['id']?>
                                <span class="provider"><?=$r['shop']['create_time']?>&nbsp;联系电话：<?=$r['shop']['tel']?>&nbsp;QQ:<?=$r['shop']['qq']?></span>
                            </td>
                            <td class="order-operation"><?php if($r['order']['type']=='normal'){
                                    switch($r['order']['state']){
                                        case 'unpaid':$state='未付款';$iClass='fa fa-exclamation-circle';
                                            $url='';$aValue='立即付款';break;
                                        case 'unshipped':$state='等待发货';$iClass='fa fa-truck';
                                            $url=WebRouter::init()->getPage('my','sendShopMsg',array('user_id'=>$r['order']['shop_id'],'order_id'=>$r['order']['id']));$aValue='催一下发货';break;
                                        case 'shipped':$state='已发货';$iClass='fa fa-send';
                                            $url='http://www.kuaidi100.com/chaxun?com='.$r['order']['express_name'].'&nu='.$r['order']['express_num'];$aValue='查看物流';break;
                                        case 'shipped_direct':$state='已发货';$iClass='fa fa-send';
                                            $url='http://www.kuaidi100.com/chaxun?com='.$v['express_name'].'&nu='.$v['express_num'];$aValue='查看物流';
                                            $url2=WebRouter::init()->getPage('orderAfter','confirm',array('id'=>$r['order']['id']));$aValue2='确认收货';break;
                                        case 'service':$state='等待服务站配送';$iClass='fa fa-truck';
                                            $url=WebRouter::init()->getPage('my','sendServiceMsg',array('user_id'=>$r['order']['service_id'],'order_id'=>$r['order']['id']));$aValue='催一下配服务站';break;
                                        case 'received':$state='已签收';$iClass='fa fa-truck';
                                            $url=WebRouter::init()->getPage('orderAfter','confirm',array('id'=>$r['order']['id']));$aValue='确认收货';break;
                                        case 'confirmed':$state='已确认收货';$iClass='fa fa-check-circle';
                                            $url=WebRouter::init()->getPage('orderAfter','comment',array('id'=>$r['order']['id']));$aValue='开始评价';break;
                                        case 'refunding':$state='退款中';$iClass='fa fa-truck';
                                            $url=WebRouter::init()->getPage('orderAfter','refund');$aValue='查看退货情况';$aValue='查看退货情况';break;
                                        case 'evaluate':$state='已评价';$iClass='fa fa-truck';
                                            $url=WebRouter::init()->getPage("order","detail",array('id'=>$r['order']['id']));$aValue='查看评价';break;
                                        case 'assigned':$state='金额已分配完毕';$iClass='fa fa-truck';
                                            $url='javascript:';$aValue='咨询客服';break;
                                        default :$state='不知道怎么了，请咨询客服';$iClass='fa fa-truck';
                                            $url='javascript:';$aValue='unknown state';
                                    }
                                }else{
                                    //service                                            $iClass='';
                                    switch($r['order']['state']){
                                        case 'unpaid':$state='未付款';$iClass='fa fa-exclamation-circle';
                                            $url='javascript:';$aValue='立即付款';break;
                                        case 'unused':$state='未使用';$iClass='';
                                            $url=WebRouter::init()->getPage('orderAfter','serviceCode',array('id'=>$r['order']['id']));$aValue='获取验证码';break;
                                        case 'used':$state='已使用';$iClass='';
                                            $url=WebRouter::init()->getPage('orderAfter','comment',array('id'=>$r['order']['id']));
                                            $aValue='评价订单';break;
                                        case 'refunding':$state='退款中';$iClass='fa fa-truck';
                                            $url=WebRouter::init()->getPage('orderAfter','refund');$aValue='查看退款情况';break;
                                        case 'evaluate':$state='已评价';$iClass='fa fa-truck';
                                            $url='javascript:';$aValue='查看评价';break;
                                        default :$state='unknown state';$iClass='fa fa-truck';
                                        $url='javascript:';$aValue='unknown state';
                                    }
                                } ?>
                                <span><i class="<?=$iClass?>"></i><?=$state?></span>
                            </td>
                        </tr>
                        <?php foreach ($r['goods'] as $k=>$v) {?>
                            <tr class="order-content" data-id="<?= $v['id']?>" >
                                <td class="cargo-img"><a href="<?php e_page('goods','index',array('id'=>$v['gopen_id'])) ?>"><img src="<?=$v['thumb']?>" alt=""></a></td>
                                <td class="cargo-name"><a href="<?php e_page('goods','index',array('id'=>$v['gopen_id'])) ?>"><?=$v['name']?></a></td>
                                <td class="cargo-price"><p><?php if(!empty($v['original_price'])){ echo '¥ '.$v['original_price' ];}?></p>¥ <?= $v['base_price' ] ?></td>
                                <td class="cargo-amount"><?=$v['number']?></td>
                            <?php if($k == 0){
                                $rowspan = count($r['goods']);?>
                                <td class="total-fee" rowspan="<?=$rowspan?>"><span><?=$r['order']['payment_amount']?></span></td>
                            <?php }?>
                                <?php if($r['order']['state']=='evaluate'&&!empty($v['comment'])) {?>

                                <td class="order-evaluation order-operation" rowspan="1" colspan="2">
                                    <p>
                                        <?php for($i=0;$i<$v['comment']['score'];$i++){ ?>
                                            <i class="fa fa-star"></i>
                                        <?php }?>
                                    </p>
                                    <p><span class="evaluation-type">我的评价：</span><span><?=$v['comment']['comment'] ?></span></p>
                                    <p class="time"><?=date('Y年m月d日 H:i',strtotime($v['comment']['create_time'])) ?></p>
<!--                                reply-->
                                        <?php if(!empty($v['comment']['reply'])){ ?>
                                    <p><span class="evaluation-type">卖家回复：</span><span><?=$v['comment']['reply'] ?></span></p>
                                    <p class="time"><?=date('Y年m月d日 H:i',strtotime($v['comment']['reply_time'])) ?></p>
                                </td>
                                    <?php }}else if($r['order']['state']=='confirmed'){?>
                                <td class="order-evaluation order-operation" rowspan="1" colspan="2">
                                        暂无评价，<a href="<?php e_page('orderAfter','comment',array('id'=>$r['order']['id'])) ?>">立即评价</a>
                                </td>
                                    <?php }else{
                                    if($k==0){?>
                                <td class="order-evaluation order-operation" rowspan="<?=$rowspan?>" colspan="2">
                                    <a href="<?= $url ?>" class="<?=$r['order']['state']?>" <?php if($aValue=='查看物流'){echo "target='_blank'";} ?>><?= $aValue ?></a>
                                    <?php if(isset($url2)){ ?>
                                        <a href="<?= $url2 ?>" class="<?=$r['order']['state']?>"><?= $aValue2 ?></a>
                                    <?php } ?>
                                </td>
                                    <?php }}?>
                            </tr>
                        <?php }?>

                    </table>                    
                </div>
                <div class="ought-to-pay">
                    <p>实付款：<span><?=$r['order']['payment_amount'] ?></span>元</p>
                </div>
                <div class="order-flow">
                    <h1>订单流程</h1>
                    <div class="order-flow-content">
                        <?php if(!empty($r['order']['payment_time'])&&$r['order']['payment_time']!='0000-00-00 00:00:00'){ ?><p>支付时间：<?=$r['order']['payment_time']?> 买家支付货款</p><?php }else{?><p>您还未付款哦~</p><?php }?>
                        <?php if(!empty($r['order']['shipping_time'])){ ?><p>发货时间：<?=$r['order']['shipping_time']?> 卖家发货</p><?php }?>
                        <?php if(!empty($r['order']['service_time'])){ ?><p>到站时间：<?=$r['order']['service_time']?> 到达服务站</p><?php }?>
                        <?php if(!empty($r['order']['deal_time'])){ ?><p>确认收货：<?=$r['order']['deal_time']?> 买家确认收货</p><?php }?>
                    </div>
                </div>
                <?php if($r['order']['type']=='normal'){?>
                <div class="take-address">
                    <h1>收货地址</h1>
                    <p class="address-name"><?=$r['userAddress']?></p>
                    <?php if(!empty($r['service'])){ ?>
                    <h1 class="service-station">服务站</h1>
                    <p class="address-name"><?=$r['service']['service_name']?></p>
                    <table>
                        <tr>
                            <td class="address-map"><img src="" alt=""></td>
                            <td class="station-location">
                                <p><span><?=$r['service']['service_name']?></span><br>
                                <span class="station-location-id">地址：<?=$r['service']['addressDetail']?></span></p>
                            </td>

                            <td class="station-evaluation">
                                <?php if($r['order']['state']=='evaluate'&&!empty($r['service']['comment'])){ ?>
                                <p><span class="evaluation-type">我的评价：</span>
                                    <?php for($i=0;$i<$r['service']['comment']['score'];$i++){ ?>
                                        <i class="fa fa-star"></i>
                                    <?php }?></p>
                                <p class="evaluation-content"><?=$r['service']['comment']['comment'] ?></p>
                                <p class="evaluation-time"><?=date('Y年m月d日 H:i',strtotime($r['service']['comment']['create_time'])) ?></p>
                                <?php if(!empty($r['service']['comment']['reply'])){ ?>
                                <p><span class="evaluation-type">服务站回复：</span><?=$r['service']['comment']['reply'] ?></p>
                                <p class="evaluation-time"><?=date('Y年m月d日 H:i',strtotime($r['service']['comment']['reply_time'])) ?></p>


                            <?php }}elseif($r['order']['state']=='confirmed'){?>
                                暂无评价，<a href="<?php e_page('orderAfter','comment',array('id'=>$r['order']['id'])) ?>">立即评价</a>
                            <?php }else{?>
                                订单完成之后，您就可以评价服务站了哦~
                            <?php }?>
                            </td>
                        </tr>
                    </table>
                    <?php }?>
                </div><?php }?>
                <div class="order-remark">
                    <h1>订单备注</h1>
                    <p><?=$r['order']['remark'] ?></p>
                </div>
            </div>
        </div>
    </div>
    <?php import_tpl("fragment/footer.php"); ?>
</div>
<div class="alert-bg order-pay">
    <div class="alert-box">
        <form id="order-pay" action="<?php e_page('order','pay') ?>" method="get">
            <input type="hidden" id="order-id" name="order_id" value="">
            <div class="alert-box-title">选择支付方式<a class="close" href="javascript:"><i class="fa fa-close"></i></a></div>
            <div class="pay-way">
                <p><input type="radio" id="pay-way-money" name="pay_way" value="money" checked>
                    <label for="pay-way-money" id="pay-way-money-label">余额支付&nbsp;&nbsp;&nbsp;&nbsp;<span>(账户余额元，余额支付元，其余元使用支付宝)</span></label></p>
                <div class="rest-pay-captcha">
                    <label for="test-code">验证码</label>
                    <input name="code" type="text" id="test-code" placeholder="请输入验证码">
                    <i class="fa fa-check-circle code-right" style="display:none;"></i><i class="fa fa-times-circle code-wrong" style="color:red;"></i>
                    <a href="javascript:" class="getCodeButton">免费获取验证码</a>
                </div>
                <input type="radio" id="alipay"  name="pay_way" value="alipay">
                <label for="alipay">
                    <img src="images/Pay.png" alt="">
                </label>
            </div>
            <a href="javascript:" class="info-affirm">确认</a>
        </form>
    </div>
</div>
</body>
</html>